package com.demo.oauth.config.properties;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import lombok.Data;

@Data
@Configuration
@ConfigurationProperties(prefix = "my.resource.permit")
public class ResourcePermitProperties {
	
	private Boolean enabled;
	
	private List<String> urls = new ArrayList<>();
	
	public String[] permitAllUrl() {
		if(this.enabled) {
			return new String[] {"/**"};
		}
		return this.urls.toArray(new String[this.urls.size()]);
	}

}
